package com.atguigu.userprofile.dao;

import com.atguigu.userprofile.bean.TaskTagRule;
import com.atguigu.userprofile.util.MysqlUtil;

import java.util.List;

/**
 * 负责task_tag_rule表数据的增删改查操作
 */
public class TaskTagRuleDao {

    /**
     * 通过TaskId获取TaskTagRule列表
     */

    public static List<TaskTagRule> selectTaskTagRuleListByTaskId(String taskId ){
        String querySql = " select ttr.id , ttr.tag_id , ttr.task_id , ttr.query_value , ttr.sub_tag_id , ti.tag_name as sub_tag_value " +
                " from task_tag_rule ttr join tag_info ti " +
                " on ttr.sub_tag_id = ti.id " +
                " where ttr.task_id = " + taskId ;
        List<TaskTagRule> taskTagRules = MysqlUtil.queryList(querySql, TaskTagRule.class, true);
        return taskTagRules ;
    }

    public static void main(String[] args) {
        List<TaskTagRule> taskTagRules = selectTaskTagRuleListByTaskId("1");
        taskTagRules.forEach(System.out::println);
    }

}
